import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import '../../../../resource/language/generated/l10n.dart';
import '../../interface/chat_room_leaf_interface.dart';

class DoufengPrivilegeDescPageModel extends ChatRoomChangeNotifier {
  @override
  onRootProxyModelCreated() {}

  @override
  observeMessage(int messageId, data) {}

  // CarMetaInfo? get carInfo => roomModel.channel?.carInfo;

  showPrivilegeUserDialog(BuildContext context) async {
    showDialog(
        context: context,
        barrierDismissible: false,
        useRootNavigator: false,
        builder: (_) {
          return Dialog(
              shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(16.0)),
              child: Container(
                decoration: BoxDecoration(
                  gradient: const LinearGradient(
                      colors: [Color(0xFF1F1C22), Color(0xFF2D292F)]),
                  borderRadius: BorderRadius.circular(16),
                ),
                child: Column(
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    const SizedBox(
                      height: 14,
                    ),
                    SizedBox(
                      height: 26,
                      child: Stack(
                        children: [
                          Center(
                            child: ShaderMask(
                              shaderCallback: (bounds) => const LinearGradient(
                                colors: <Color>[
                                  Color(0xFFFAD1B3),
                                  Color(0xFFFFEDC6),
                                ],
                              ).createShader(bounds),
                              child: Text(
                                T.current.df_privilege,
                                style: const TextStyle(
                                    fontSize: 18,
                                    fontWeight: FontWeight.w500,
                                    color: Colors.white),
                              ),
                            ),
                          ),
                          Align(
                            alignment: Alignment.centerRight,
                            child: Padding(
                              padding: const EdgeInsets.only(right: 23),
                              child: CupertinoButton(
                                minSize: 0,
                                padding: EdgeInsets.zero,
                                onPressed: () async {
                                  // var endPrivilege = await handleRsp(() =>
                                  //     AutoRideApi.instance.endPrivilege());
                                  // if (context.mounted &&
                                  //     endPrivilege.isSuccess) {
                                  //   Navigator.pop(context);
                                  // }
                                },
                                child: Row(
                                  mainAxisSize: MainAxisSize.min,
                                  children: [
                                    Image.asset(
                                      "assets/images/ic_operate_end.png",
                                      width: 12,
                                      height: 12,
                                      fit: BoxFit.contain,
                                    ),
                                    const SizedBox(
                                      width: 5,
                                    ),
                                    // if (UserManager.instance.currentUser!.job ==
                                    //     Job.BOSS)
                                    Text(
                                      T.current.ending,
                                      style: const TextStyle(
                                        fontSize: 12,
                                        fontWeight: FontWeight.w400,
                                        color: Color(0xff999999),
                                      ),
                                    ),
                                  ],
                                ),
                              ),
                            ),
                          )
                        ],
                      ),
                    ),
                    const SizedBox(
                      height: 9,
                    ),
                    Container(
                      decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(8),
                        color: const Color(0xFF757575)
                            .withAlpha((0.1 * 255).toInt()),
                      ),
                      padding: const EdgeInsets.only(
                          top: 13, left: 15.5, right: 15.5),
                      margin: const EdgeInsets.symmetric(horizontal: 12),
                      child: const Column(
                        mainAxisSize: MainAxisSize.min,
                        children: [
                          Text(
                            'privilegeDesc',
                            style: TextStyle(
                              fontSize: 12,
                              fontWeight: FontWeight.w400,
                              color: Color(0xFFD5C3B2),
                            ),
                          ),
                          SizedBox(
                            height: 8,
                          ),
                          Text(
                            'privilegeExtDesc',
                            style: TextStyle(
                              fontSize: 12,
                              fontWeight: FontWeight.w400,
                              color: Colors.white,
                            ),
                          )
                        ],
                      ),
                    ),
                    const SizedBox(
                      height: 30,
                    ),
                  ],
                ),
              ));
        });
  }

  Future<bool> confirm(BuildContext context, bool hasPrivilege) async {
    // if (hasPrivilege) {
    //   var result =
    //       await AutoRideApi.instance.usePrivilege(roomModel.channel!.channelId);
    //   if (result.isSuccess) {
    //     Navigator.of(context).pop();
    //   } else {
    //     showToast(result.errorMsg ?? T.current!.check_network_retry);
    //   }
    return true;
    // }
    // return false;
  }
}
